<?php
/**
 * Created by PhpStorm.
 * User: laowang
 * Date: 2018/3/23
 * Time: 下午1:35
 */

namespace app\home\model;
use think\Model;
use app\home\model\Course;
class CourseSign extends Model
{
    public function get_list($where,$len=0){
        $list = $this->where($where)->order('create_time','desc')->limit($len,12)->select();
        $arr = [];
        foreach ($list as $value){
            $Course = Course::where(['id' => $value['c_id'],'status' => 0])->find();
            $data = [
                'start_time' => date('Y-m-d H:i',$Course['start_time']),
                'end_time' => date('Y-m-d H:i',$Course['end_time']),
                'name' => $Course['name'],
                'teacher' => $Course['teacher'],
                'id' => $Course['id'],
                'project' => str_replace('——','、',$Course['project_name'])
            ];
            array_push($arr,$data);
        }
        array_multisort(array_column($arr,'start_time'),SORT_DESC ,$arr);
        return $arr;
    }
}